home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / ARASAN_S.ZIP / PINFO.CPP < prev    next >
C/C++ Source or Header  |  1994-07-31  |  1KB  |  46 lines

  1. // Copyright 1993 by Jon Dart. All Rights Reserved.
  2.  
  3. #include "pinfo.h"
  4. #include <assert.h>
  5.  
  6. Position_Info::Position_Info( const Board &board, int rep_count )
  7. {
  8.     my_hashcode = board.HashCode();
  9.     int16 x = (int16)(board.CastleStatus(Black));
  10.     int16 y = (int16)(board.CastleStatus(White));
  11.     int16 z = (int16)(board.EnPassantSq(board.OppositeSide()));
  12.     my_xhashcode = x | (y << 3) | (z << 8) | (rep_count << 6);
  13.     if (board.Side() == Black)
  14.       my_xhashcode |= 0x8000;
  15. }
  16.  
  17. Position_Info::Position_Info( const Board &board, const int depth,
  18.                          const ValueType hashflags,
  19.                   const Boolean forced,
  20.                   const int rep_count,
  21.                   const int value,
  22.                   const Move &best_move)
  23. :  my_depth((signed char)depth),
  24.    my_hashcode(board.HashCode()),
  25.    my_value(value),my_best_move(best_move)
  26. {
  27.     my_flags = (byte)hashflags;
  28.     if (forced)
  29.         my_flags |= 0x80;
  30.     assert(rep_count <= 3);
  31.     // The "xhashcode" byte holds info on castling and en passant
  32.     // status.
  33.     int16 x = (int16)(board.CastleStatus(Black));
  34.     int16 y = (int16)(board.CastleStatus(White));
  35.     int16 z = (int16)(board.EnPassantSq(board.OppositeSide()));
  36.     my_xhashcode = x | (y << 3) | (z << 8) | (rep_count << 6);
  37.     if (board.Side() == Black)
  38.       my_xhashcode |= 0x8000;
  39. }
  40.  
  41. unsigned long hash_code(const Position_Info &p)
  42. {
  43.     return p.hash_code();
  44. }
  45.  
  46.